<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:sec="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="admin/common/html/tableHead :: head(~{::title},~{::link},~{::style})">

	<title th:text=${title}></title>
	<!-- 这儿引用单独的css link -->
	<!-- Ladda for Bootstrap 3按钮加载进度插件 -->
	<link rel="stylesheet" th:href="@{/static/admin/assets/js/button/ladda/ladda.min.css}">
	<!-- bootstrap-table表单样式 -->
	<link th:href="@{/static/admin/assets/js/bootstrap/css/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>

	<!-- bootstrap-fileinput上传文件样式 -->
	<link th:href="@{/static/admin/assets/js/bootstrap/css/fileinput.css}" rel="stylesheet"/>

	<!--wangrditor富文本编辑器样式-->
	<link th:href="@{/static/admin/assets/js/wangEditor/wangEditor1.css}" rel="stylesheet"/>
	<!-- 用户界面自定义css -->
	<link th:href="@{/static/admin/user/css/user-add.css}" rel="stylesheet"/>
	<style type="text/css">
		.w-e-toolbar {
			flex-wrap: wrap;
		}
	</style>
</head>

<body>

<div class="content-wrap">
	<div class="row">
		<div class="col-sm-12">
			<div class="nest" id="elementClose">
				<div class="">
				</div>
				<div class="body-nest" id="element">
					<div class="panel-body">
						<form  class="form-horizontal m" id="form-add" th:object="${TAbbGoods}">
							<input type="hidden" id="id" name="id" th:value="*{id}" readonly/>
							<div class="form-group">
								<label class="col-sm-3 control-label ">商品名称：</label>
								<div class="col-sm-8">
									<input class="form-control" type="text" id="goodsname" th:value="*{goodsname}" readonly/>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label ">商品图片：</label>
								<div class="col-sm-8">
									<div class="col-sm-8">
										<img th:each="image,imageList : ${#strings.listSplit(TAbbGoods.goodsimages,',')}" th:src="${image}" height="10%" width="15%"/>
									</div>
									<!--<input class="form-control" type="text" id="goodsimages" name="goodsimages"/>-->
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label ">商品详情(图文)：</label>
								<div class="col-sm-8">
									<div id="div1"></div>
									<textarea id="text1" name="content" style="width:100%; height:200px;display: none" th:text="*{goodscontent}" readonly></textarea>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label ">商品原价(单位:元)：</label>
								<div class="col-sm-8">
									<input class="form-control" type="text" id="goodsyuanprice" th:value="*{goodsyuanprice}" readonly/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label ">商品售价(单位:元)：</label>
								<div class="col-sm-8">
									<input class="form-control" type="text" id="goodsyunsongprice" th:value="*{goodsyunsongprice}" readonly/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label ">是否是抢购商品：</label>
								<div class="col-sm-8">
									<label class="radio-inline">
										<input type="radio" th:checked="${TAbbGoods.isqianggou==0}" value="0" readonly> 不是
									</label>
									<label class="radio-inline">
										<input type="radio"  th:checked="${TAbbGoods.isqianggou==1}" value="1" readonly> 是
									</label>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label ">审核：</label>
								<div class="col-sm-8">
									<label class="radio-inline">
										<input type="radio" name="status" value="2"> 审核通过
									</label>
									<label class="radio-inline">
										<input type="radio" name="status" value="3"> 审核不通过
									</label>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label ">审核失败原因：</label>
								<div class="col-sm-8">
									<input class="form-control" type="text" id="failreason" name="failreason"/>
								</div>
							</div>
							<div class="form-group">
								<div class="form-control-static col-sm-offset-9">
									<button class="btn btn-primary">提交</button>
									<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- 通用js -->
<div th:include="admin/common/html/js :: onload_js">

</div>
<!-- bootstarp 表格 -->
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/bootstrap-table.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/base_list.js}" type="text/javascript"></script>


<!-- 弹窗 -->
<script  th:src="@{/static/admin/assets/js/layer/layer.js}" type="text/javascript"></script>
<!-- 遮罩层 -->
<script  th:src="@{/static/admin/assets/js/blockUI/jquery.blockUI.js}" type="text/javascript"></script>
<!-- jqueryForm序列化 -->
<script  th:src="@{/static/js/jqueryFormSerializeJson.js}" type="text/javascript"></script>

<!-- bootstrap-fileinut上p传文件js -->
<script th:src="@{/static/admin/assets/js/bootstrap/js/fileinput.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/zh.js}" type="text/javascript"></script>
<!--wangeditor富文本编辑器js-->
<script th:src="@{/static/admin/assets/js/wangEditor/wangEditor1.js}" type="text/javascript"></script>
<script type="text/javascript">

	//wangeditor富文本编辑器开始
	var E = window.wangEditor
	var editor = new E('#div1')
	editor.customConfig.debug = true;
	editor.customConfig.uploadImgServer = rootPath+"/FileController/upload3";
	editor.customConfig.uploadFileName = 'myfiles';  //  与后台获取文件名相同
	editor.customConfig.uploadImgHooks = {
		// 如果服务器端返回的不是 {errno:0, data: [...]} 这种格式，可使用该配置
		// （但是，服务器端返回的必须是一个 JSON 格式字符串！！！否则会报错）
		customInsert: function (insertImg, result, editor) {
			debugger
			// 图片上传并返回结果，自定义插入图片的事件（而不是编辑器自动插入图片！！！）
			// insertImg 是插入图片的函数，editor 是编辑器对象，result 是服务器端返回的结果
			// 举例：假如上传图片成功后，服务器端返回的是 {url:'....'} 这种格式，即可这样插入图片：
			for(var i=0;i<result.length;i++){//上传完毕，将文件名返回
				var url = result[i].pathUrl;
				insertImg(url);
			};
			// result 必须是一个 JSON 格式字符串！！！否则报错
		}
	};
	var $text1 = $('#text1');
	editor.customConfig.onchange = function (html) {
		// 监控变化，同步更新到 textarea
		$text1.val(html)
	}
	editor.create();
	editor.$textElem.attr('contenteditable', false);

	var content=$text1.val();
	//初始化编辑器里的内容
	editor.txt.html(content);
	// 初始化 textarea 的值
	//$text1.val(editor.txt.html())
	//wangeditor富文本编辑器结束


	$(function(){
		$(".MyDate").datetimepicker({
			format: "yyyy-mm-dd hh:00:00",
			startDate: new Date(),
			autoclose: true,
			todayBtn: true,
			language: 'zh-CN',
			initialDate:new Date(),
			minView: 1
		});

	})

	$("#form-add").validate({
		rules:{
			status:{
				required:true
			},
		},
		submitHandler:function(form){
			add();
		}
	});

	/**
	 * 用户添加方法
	 */
	function add() {
		var dataFormJson=$("#form-add").serialize();
		$.ajax({
			cache : true,
			type : "POST",
			url : rootPath + "/TAbbDGoodsController/shenhe",
			data : dataFormJson,
			async : false,
			error : function(request) {
				$.modal.alertError("系统错误");
			},
			success : function(data) {
				$.operate.saveSuccess(data);
			}
		});
	}


</script>


</body>


</html>
